package com.hanter.demo.raddemo

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.Navigation
import androidx.navigation.ui.AppBarConfiguration
import com.hanter.android.radui.navigation.NavigationUtil
import kotlinx.android.synthetic.main.activity_title_bar.*

class TitleBarActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_title_bar)

        titleBar.title = "test"
        titleBar.leftBar.setOnClickListener(View.OnClickListener {
            onBackPressed()
        })

        tabBar.addTab(R.id.one_fragment, R.drawable.ic_tab_home, "test1")
        tabBar.addTab(R.id.two_fragment, R.mipmap.ic_launcher, "test2")
        tabBar.addTab(R.id.three_fragment, R.mipmap.ic_launcher, "test3")

        val navController = Navigation.findNavController(this, R.id.navHost)

        val appBarConfiguration = AppBarConfiguration.Builder(
            R.id.one_fragment, R.id.two_fragment, R.id.three_fragment)
            .build()

        NavigationUtil.setupTitleBarWithNavController(titleBar, navController, appBarConfiguration)
        NavigationUtil.setupWithNavController(tabBar, navController)
    }
}
